﻿using System;
using System.Collections.Generic;
using System.Text;

namespace JieKou.Tools
{
    public class IOPortParity
    {
        public static System.IO.Ports.Parity MakeChangeParityString(string parityStr)
        {
            System.IO.Ports.Parity result = System.IO.Ports.Parity.None;
            switch (parityStr)
            {
                case "None":
                    result = System.IO.Ports.Parity.None;
                    break;
                case "Odd":
                    result = System.IO.Ports.Parity.Odd;
                    break;
                case "Even":
                    result = System.IO.Ports.Parity.Even;
                    break;
                case "Mark":
                    result = System.IO.Ports.Parity.Mark;
                    break;
                case "Space":
                    result = System.IO.Ports.Parity.Space;
                    break;
                default:
                    break;
            }
            return result;
        }

        public static System.IO.Ports.StopBits MakeChangeStopBitsString(string stopBitsStr)
        {
            System.IO.Ports.StopBits result = System.IO.Ports.StopBits.None;
            switch (stopBitsStr)
            {
                case "None":
                    result = System.IO.Ports.StopBits.None;
                    break;
                case "One":
                    result = System.IO.Ports.StopBits.One;
                    break;
                case "Two":
                    result = System.IO.Ports.StopBits.Two;
                    break;
                case "OnePointFive":
                    result = System.IO.Ports.StopBits.OnePointFive;
                    break;
                default:
                    break;
            }
            return result;
        }
    }
}
